<?php
include_once 'modules/mail/models/Mail.php';
include_once 'modules/user/models/User.php';

class support_contactSticker extends Nine_Sticker
{
	public function run()
	{
	/**
         * Get post data
         */
		$data = Nine_Controller_Front::getInstance()->getRequest()->getParam('sup', false);
        $error = array();    
            
        if (false != $data) {
            
                try {
                        /**
                         * Get admin
                         */
                        $objUser = new Models_User();
                        $admin = $objUser->getByUserName('admin');
                        /**
                         * Send message
                         */
                        $objMail = new Models_Mail();
                        /**
                         * Send to admin
                         */
                        $objMail->sendHtmlMail('contact', $data, $admin['email'],null, $admin['email']);
                        
                        $this->session->contactMessage = array(
                                                               'success' => true,
                                                               'message' => Nine_Language::translate('Message is send successfully')
                                                           );
                    }
                catch (Exception $e) {
                     $this->session->contactMessage = array(
                                                       'success' => false,
                                                       'message' => Nine_Language::translate('Can NOT send this message. Please try again')
                                                   );
                }
                
            
        }

        /**
         * Setbanner
         */
        $this->session->frontBanner = 'front/images/img/banner_01.jpg';
        
        /**
         * Assign to view
         */
        $this->view->randomNumber = rand(0, 1000000);
        $this->view->data = $data;
        $this->view->contactMessage = $this->session->contactMessage;
        $this->session->contactMessage = null;
        
        
	}
}